/**!
 *
 * 添加用户。
 *
 */

$(function () {
    /** 用户表单的 jQuery 对象 */
    var $userForm = $("#user_form");
    /** 显示校验信息的容器 */
    var $validatecontainer = $("#validate_container");
    /** 添加按钮的 jQuery 对象 */
    var $updateUserBtn = $userForm.find("button[name='updateUserBtn']");

    $userForm.validate({
        rules: {
            loginName: {
                required: true,
                maxlength: 50,
            },
            collieryNo: {
                maxlength: 20
            },
            industryCode: {
                required: true
            },
            isAdmin: {
                required: true
            },
            isLeader: {
                required: true
            }
        },
        messages: {
            loginName: {
                required: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>请输入姓名</span>",
                maxlength: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>姓名的长度不能大于{0}个字</span>"
            },
            collieryNo: {
                maxlength: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>企业编码的长度不能大于{0}个字符</span>"
            },
            industryCode: {
                required: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>请选择所属行业</span>"
            },
            isAdmin: {
                required: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>请选择用户类型</span>"
            },
            isLeader: {
                required: "<span class='f-s-12'><i class='iconfont icon-error f-s-12'></i>请选择是否为领导</span>"
            }
        },
        errorContainer: $validatecontainer,
        errorLabelContainer: $("ul", $validatecontainer),
        wrapper: "li",
        submitHandler: function (form) {
            $updateUserBtn.html("<i class='ace-icon fa fa-spinner fa-spin bigger-150'></i>正在修改…").attr({"disabled": "disabled"});

            return true;
        }
    });
});